package main

import (
	"bytes"
	"encoding/binary"
	"fmt"
)

//  int  to byte
func intToByte(n int) []byte {
	data := int64(n)
	bytebuffer := bytes.NewBuffer([]byte{})

	binary.Write(bytebuffer, binary.BigEndian, data)

	return bytebuffer.Bytes()
}

func byteToInt(bts []byte) int {

	bytebuffer := bytes.NewBuffer(bts)
	var data int64
	binary.Read(bytebuffer, binary.BigEndian, &data)

	return int(data)
}

func mainB() {

	fmt.Println(intToByte(257))
	fmt.Println(byteToInt(intToByte(257)))

}
